package com.ruoyi.wechat.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.wechat.domain.Banner;
import com.ruoyi.wechat.service.IBannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "广告列表", tags = {"广告列表"})
@RestController
@RequestMapping("/wechat/banner")
public class WxBannerController extends BaseController {
    @Autowired
    private IBannerService bannerService;

    /**
     * 查询广告列表列表
     */
    @ApiOperation("查询广告列表列表")
    @GetMapping("/list")
    public TableDataInfo list(Banner banner){
        List<Banner> list = bannerService.selectBannerList(banner);
        return  getDataTable(list);
    }
//    /**
//     * 查询广告列表列表
//     */
//    @ApiOperation("查询广告列表列表")
//    @GetMapping("/list")
//    public TableDataInfo list(String state){
//        List<Banner> list = bannerService.selectBannerList(state);
//        return  getDataTable(list);
//    }

    /**
     * 获取广告详细信息
     */
    @ApiOperation("查询广告列表详细信息")
    @GetMapping(value = "/{bannerId}")
    public AjaxResult getInfo(@PathVariable("bannerId") Integer bannerId)
    {
        return success(bannerService.selectBannerByBannerId(bannerId));
    }
}
